class Tab_TaskforcesGameType extends UT2K4Tab_GameTypeBase;


function PopulateGameTypes()
{
    local int i,cnt;
    local class<TFGame> tempGametype;
    local array<CacheManager.GameRecord> CustomGametypes;

    class'CacheManager'.static.GetGameTypeList(GameTypes);

    li_Games.Add(EpicGameCaption,None,"",true);
    for (i = 0; i < GameTypes.Length; i++)
    {
        tempGametype = class<TFGame>(DynamicLoadObject(GameTypes[i].ClassName, class'Class'));
		if ( tempGametype != none && HasMaps(GameTypes[i]) )
		{
			if (tempGametype == class'Taskforces.TFGame')
			{
			    log("Found TFGame.");
                li_Games.Add(GameTypes[i].GameName, None, GameTypes[i].MapListClassName);
//	            AddEpicGameType( GameTypes[i].GameName, GameTypes[i].MapListClassName);
	        }
			else if (tempGametype != class'Taskforces.TFGame' && HasMaps(GameTypes[i]) && ClassIsChildOf(tempGametype, class'Taskforces.TFGame'))
			{
				cnt++;
			    log("Found Custom TFGame. Cnt: "$cnt);
                CustomGametypes.Insert(0,1);
                CustomGametypes[0] = GameTypes[i];
			}
		}
		else if (tempGametype != none && !HasMaps(GameTypes[i]))
		{
			Log("Gametype"@GameTypes[i].ClassName@"found but it has no maps", 'Warning');
		}
    }

//	li_Games.SortList();

//    	li_Games.Insert(0,EpicGameCaption,None,"",true,true);
//    	li_Games.SetIndex(1);

	    li_Games.Add(CustomGameCaption,None,"",true);
//	}

	if (cnt>0)
	{
	    for (i = 0; i < CustomGametypes.Length; i++)
	    {
	       log("Adding Custom GameType.");
           li_Games.Add(CustomGameTypes[i].GameName, None, CustomGameTypes[i].MapListClassName);
//           AddEpicGameType( CustomGameTypes[i].GameName, CustomGameTypes[i].MapListClassName);
        }
    }
}

defaultproperties
{
}
